<!--资源管理-->
<template>
  <div class="resource-manage">
    <a-card size="small" :headStyle="{ background: '#f9f9f9' }" :bodyStyle="{ height: 'calc(100% - 48px)' }">
      <div slot="title">
        <div class="top-icon">
          <icon-font type="icon-resource-management" />
        </div>
        <span>资源管理</span>
      </div>
      <div slot="extra">
        <a-button type="primary" icon="plus" @click="resourceClick('add')">新增资源管理</a-button>
      </div>
      <!-- 资源管理表格 -->
      <el-table
        :data="resourceTableData"
        highlight-current-row
        border
        height="100%"
        :row-style="{height:'40px'}"
        :cell-style="{padding:'0px'}"
        :header-cell-style="{background: '#FAFAFA', padding: 0, height: '40px', color: '#666666'}"
        style="width: 100%">
        <slot v-for="(item,index) in resourceColumns">
          <el-table-column
            :key="index"
            :property="item.field"
            :label="item.title"
            :width="item.width"
            show-overflow-tooltip
            sortable>
          </el-table-column>
        </slot>
        <el-table-column label="操作">
          <template>
            <a @click="resourceClick('edit')">编辑</a>
            <a-divider type="vertical" />
            <a @click="resourceClick('del')">删除</a>
          </template>
        </el-table-column>
      </el-table>
    </a-card>

    <!-- 资源管理弹出框 -->
    <a-modal
      :maskClosable="false"
      :title="modalTitle"
      v-model="dialogFormVisible">
      <a-form
        :label-col="{ span: 6 }"
        :wrapper-col="{ span: 18 }"
        :form="form">
        <a-form-item label="顺序号">
          <a-input type="number" v-decorator="[ 'MS_Order', {rules: [{ required: true, message: '请输入顺序号!' }]} ]" />
        </a-form-item>
        <a-form-item label="模块名称" >
          <a-input v-decorator="[ 'MS_ModuleName', {rules: [{ required: true, message: '请输入模块名称!' }]} ]" />
        </a-form-item>
        <a-form-item label="模块视图">
          <a-input v-decorator="[ 'MS_View', {rules: [{ required: true, message: '请输入模块视图!' }]} ]" />
        </a-form-item>
        <a-form-item label="模块模型">
          <a-input v-decorator="[ 'MS_ViewModel', {rules: [{ required: true, message: '请输入模块模型!' }]} ]" />
        </a-form-item>
        <a-form-item label="链接视图">
          <a-input v-decorator="[ 'MS_MoreView' ]" />
        </a-form-item>
        <a-form-item label="链接模型">
          <a-input v-decorator="[ 'MS_MoreViewModel' ]" />
        </a-form-item>
        <a-form-item label="记录时间">
          <a-input disabled v-decorator="[ 'MS_CreateDate' ]" />
        </a-form-item>
        <a-form-item label="相关备注">
          <a-input v-decorator="[ 'MS_Remark' ]" />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>

<script>
export default {
  name: 'ResourceManage',
  components: {
  },
  data () {
    return {
      modalTitle: '', // 资源管理弹出框标题
      dialogFormVisible: false, // 资源管理弹出框显示与隐藏
      form: this.$form.createForm(this),
      resourceTableData: [ // 资源管理表格数据
        {
          MS_Order: '1',
          MS_ModuleName: '新闻管理',
          MS_View: 'newsCenter',
          MS_ViewModel: 'newsCenter',
          MS_MoreView: 'newsCenter',
          MS_MoreViewModel: 'newsCenter',
          MS_CreateDate: '2020-09-18'
        }
      ],
      resourceColumns: [ // 资源管理表头数据
        {
          title: '顺序号',
          field: 'MS_Order'
        },
        {
          title: '模块名称',
          field: 'MS_ModuleName'
        },
        {
          title: '模块视图',
          field: 'MS_View'
        },
        {
          title: '模块模型',
          field: 'MS_ViewModel'
        },
        {
          title: '链接视图',
          field: 'MS_MoreView'
        },
        {
          title: '链接模型',
          field: 'MS_MoreViewModel'
        },
        {
          title: '记录时间',
          field: 'MS_CreateDate'
        }
      ]
    }
  },
  created () {
  },
  mounted () {
  },
  methods: {
    // 资源管理按钮事件 val代表类型，add：资源管理新增，edit：资源管理编辑，del：资源管理删除
    resourceClick (val) {
      switch (val) {
        case 'add':
          this.modalTitle = '资源管理新增'
          this.dialogFormVisible = true
          this.form.resetFields() // 表单清空
          break
        case 'edit':
          this.modalTitle = '资源管理编辑'
          this.dialogFormVisible = true
          break
        case 'del':
          var this_ = this
          this.$confirm({
            title: '提示',
            content: '此操作将永久删除该文件, 是否继续?',
            okText: '确认',
            cancelText: '取消',
            onOk () {
              this_.$message.success('删除成功')
            }
          })
          break
        default:
          break
      }
    }
  }
}
</script>
<style lang="less" scoped>
.resource-manage {
  width: 100%;
  height: 100%;
  padding: 10px 10px 0;
  background: #f0f2f5;
}
</style>
